#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time : 2025/7/13 2:39
# @Author : liuqi
# @File : views.py
# @Software: PyCharm
# @Describe:
import logging

from ...models import User
from info.modules.index import index_blue
from flask import session, render_template
from flask import current_app



@index_blue.route('/', methods=['GET', 'POST'])
def hello_world():
    # 1.获取用户登录信息
    user_id = session.get('user_id')
    # 2.通过user_id获取用户信息
    user = None
    if user_id:
        try:
            user = User.query.get(user_id)
        except Exception as e:
            logging.error(e)
    #3.拼接用户信息
    data = {
        'user_info':user.to_dict() if user else '',
    }
    print(data)
    return render_template("news/index.html",data=data)

# 处理网站logo
@index_blue.route('/favicon.ico')
def get_web_logo():
    return current_app.send_static_file('news/favicon.ico')